package easy;

import java.util.HashSet;

/**
 * @author admin
 * 1684. 统计一致字符串的数目
 * 时间复杂度为O（N+M）
 */
public class LeeCode1684 {

    public int countConsistentStrings(String allowed, String[] words) {

        HashSet<Character> set = new HashSet<>();
        for (char c : allowed.toCharArray()) {
            set.add(c);
        }
        int count = 0;
        for (String word : words) {
            for (char c : word.toCharArray()) {
                if (!set.contains(c)){
                    count++;
                    break;
                }
            }
        }
        return words.length - count;
    }

    public static void main(String[] args) {
        System.out.println(new LeeCode1684().countConsistentStrings("abc", new String[]{"a", "b", "c", "ab", "ac", "bc", "abc"}));
    }
}
